#ifndef TILESELECTSCENE_H
#define TILESELECTSCENE_H

#include <QGraphicsScene>

class QPixmap;
class QPainter;

class TileSelectScene : public QGraphicsScene
{
    Q_OBJECT

public:
    TileSelectScene();
     ~TileSelectScene();
    void load(QString filename, qint32 tileW, qint32 tileH);
    void drawForeground(QPainter *painter, const QRectF &rect);
    void drawBackground(QPainter *painter, const QRectF &rect);

signals:
    void selectedTileChanged(qint32 tileNum);

protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);

private:
    QPoint getTileInfo(QPointF position);
    qint32 getTileNum(QPoint &tile) const;

    QPixmap *pixmap;
    qint32 tileSizeX;
    qint32 tileSizeY;

    bool editing;
    QPoint selectedTile;
};

#endif // TILESELECTSCENE_H
